package com.tencreat.service.mall.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.tencreat.common.core.domain.model.ReqStringParam;
import com.tencreat.domain.mall.MallMultipleOrder;
import com.tencreat.mapper.mall.MallMultipleOrderMapper;
import com.tencreat.service.mall.IMallMultipleOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单关联Service业务层处理
 *
 * @author tencreat
 * @date 2022-01-17
 */
@Service
public class MallMultipleOrderServiceImpl extends ServiceImpl<MallMultipleOrderMapper, MallMultipleOrder> implements IMallMultipleOrderService {


    @Autowired
    private MallMultipleOrderMapper mallMultipleOrderMapper;

    /**
     * 查询订单关联
     *
     * @param muOrderId 订单关联ID
     * @return 订单关联
     */
    @Override
    public MallMultipleOrder selectMallMultipleOrderById(ReqIdParam muOrderId) {
        return baseMapper.selectById(muOrderId.getId());
    }

    /**
     * 查询订单关联
     *
     * @param muOrderId 订单关联ID
     * @return 订单关联
     */
    @Override
    public List<MallMultipleOrder> selectByMuOrderId(ReqStringParam muOrderId) {
        return mallMultipleOrderMapper.selectByMuOrderId(muOrderId.getCommon());
    }

    /**
     * 查询订单关联列表
     *
     * @param mallMultipleOrder 订单关联
     * @return 订单关联
     */
    @Override
    public List<MallMultipleOrder> selectMallMultipleOrderList(MallMultipleOrder mallMultipleOrder) {
        return baseMapper.selectList(Wrappers.query(mallMultipleOrder));
    }

    /**
     * 新增订单关联
     *
     * @param mallMultipleOrder 订单关联
     * @return 结果
     */
    @Override
    public int insertMallMultipleOrder(MallMultipleOrder mallMultipleOrder) {
        return mallMultipleOrderMapper.insertMallMultipleOrder(mallMultipleOrder);
    }

    /**
     * 修改订单关联
     *
     * @param mallMultipleOrder 订单关联
     * @return 结果
     */
    @Override
    public int updateMallMultipleOrder(MallMultipleOrder mallMultipleOrder) {
        return baseMapper.updateById(mallMultipleOrder);
    }

    /**
     * 批量删除订单关联
     *
     * @param muOrderIds 需要删除的订单关联ID
     * @return 结果
     */
    @Override
    public int deleteMallMultipleOrderByIds(ReqIdsParam muOrderIds) {
        return baseMapper.deleteBatchIds(muOrderIds.getId());
    }

    /**
     * 删除订单关联信息
     *
     * @param muOrderId 订单关联ID
     * @return 结果
     */
    @Override
    public int deleteMallMultipleOrderById(ReqIdParam muOrderId) {
        return baseMapper.deleteById(muOrderId.getId());
    }
}
